<%--
  Created by IntelliJ IDEA.
  User: HUAWEI
  Date: 2024/1/1
  Time: 0:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="service.AdminService" %>
<%@ page import="domain.News" %>
<%@ page import="java.util.List" %>

<html>
<head>
    <title>新闻管理</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">

    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script>
    <style>
        /* 设置a标签样式*/
        a {
            color: black; /* 设置字体为白色 */
        }

        a:hover {
            color: red;
            text-decoration: none; /* 去除下划线效果 */
        }
    </style>
</head>
<body>
<%@include file="header.jsp"%>

<div class="row" style="padding-top: 10px;padding-bottom: 10px">
    <div class="col-1"></div>
    <div class="col-4">
        <a href="../admin/index.jsp" type="button" class="btn btn-primary">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-house-door-fill" viewBox="0 0 16 16">
                <path d="M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z"/>
            </svg>
            首页
        </a>
    </div>
    <div class="col-2"><h4>新闻管理页面</h4></div>
    <div class="col-3">
        <form method="get" action="newsManagement">
            <div class="input-group mb-3">
                <input type="text" name="search" class="form-control" <%--placeholder="输入搜索内容..." aria-label="输入搜索内容..."--%> <%--aria-describedby="button-addon2"--%>>
                <div class="input-group-append">
                    <button class="btn btn-dark btn-xs" type="submit" <%--id="button-addon2"--%>>搜索</button>
                </div>
            </div>
        </form>
    </div>



    <div class="col-2">
        <a href="${pageContext.request.contextPath}/admin/addNews.jsp" type="button" class="btn-lg btn-success">
<%--            <i class="bi bi-plus-square">--%>
                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
                     class="bi bi-plus-square" viewBox="0 0 16 16">
                    <path d="M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"/>
                    <path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z"/>
                </svg>
                添加新闻
<%--            </i>--%>
        </a>
    </div>
</div>
<div class="row">
    <div class="col-1"></div>
    <div class="col-10">
        <table class="table table-bordered">
            <thead>
            <tr>
                <th scope="col">编号</th>
                <th scope="col">新闻类型</th>
                <th scope="col">新闻标题</th>
                <th scope="col">发布日期</th>
                <th scope="col">操作</th>
            </tr>
            </thead>
            <tbody>
            <%--  ${newsDataList}--%>
            <c:forEach items="${newsDataList}" var="newsData" varStatus="number">
                <tr>
                    <th scope="row">${number.index+1}</th>
                    <td class="col-1">${newsData.newsTypeName}</td>
                    <td class="col-6">${newsData.newsTitle}</td>
                    <td class="col-2">${newsData.newsDate}</td>
                    <td class="col-2">
                        <a href="${pageContext.request.contextPath}/admin/modifyData?newsId1=${newsData.newsId}" type="button"
                           class="btn btn-success">修改</a>
                        <a href="${pageContext.request.contextPath}/admin/modifyData?newsId2=${newsData.newsId}" type="button"
                           class="btn btn-danger">删除</a>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
    <div class="col-1"></div>
</div>

            <nav aria-label="Page navigation example">
                <ul class="pagination justify-content-center">
                    <c:if test="${reqAdminPageIndex != 1}">
                        <li class="page-item">
                            <a class="page-link"
                               href="${pageContext.request.contextPath}/admin/newsManagement?reqPageIndex=${reqAdminPageIndex > 0 ? reqAdminPageIndex - 1 : 1}">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                    </c:if>

                    <c:forEach begin="1" end="${pageCount}" var="pageNum">
                        <li class="page-item ${reqAdminPageIndex == pageNum ? 'active' : ''}">
                            <a class="page-link"
                               href="${pageContext.request.contextPath}/admin/newsManagement?reqPageIndex=${pageNum}">
                                    ${pageNum}
                            </a>
                        </li>
                    </c:forEach>

                    <c:if test="${reqAdminPageIndex != pageCount}">
                        <li class="page-item">
                            <a class="page-link"
                               href="${pageContext.request.contextPath}/admin/newsManagement?reqPageIndex=${reqAdminPageIndex < pageCount ? reqAdminPageIndex + 1 : pageCount}">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </c:if>

                    <li class="page-item disabled">
                        <span class="page-link">${total}条数据</span>
                    </li>
                    <li class="page-item disabled">
                        <span class="page-link">共${pageCount}页</span>
                    </li>
                </ul>
            </nav>



</body>
</html>

